package com.yuanduan.mplus.view;

import android.view.View;
import android.widget.TextView;

import com.cj.framework.app.BaseActivity;
import com.cj.framework.app.BaseApplication;
import com.cj.framework.util.RSAUtils;
import com.yuanduan.mplus.R;
import com.yuanduan.mplus.config.Config;
import com.yuanduan.mplus.db.dao.UserDao;

import java.util.List;

public class StartActivity extends BaseActivity implements View.OnClickListener {
    private TextView tv_login;
    private TextView tv_register;

    @Override
    protected void findId() {
        tv_login= (TextView) findViewById(R.id.start_tv_login);
        tv_register= (TextView) findViewById(R.id.start_tv_register);
    }

    @Override
    protected void logic() {
        RSAUtils.loadPublicKey(Config.RSA_PUBLIC);
        //启动是否进入主界面
        UserDao userDao= BaseApplication.getDaoSession().getUserDao();
        List list=userDao.queryBuilder().list();
        if(list.size()!=0){
            openActivity(Main1Activity.class);
        }
        //设置监听器
        tv_register.setOnClickListener(this);
        tv_login.setOnClickListener(this);
    }

    @Override
    protected int setLayout() {
        return R.layout.activity_start;
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.start_tv_login:
                openActivity(LoginActivity.class);
                break;
            case R.id.start_tv_register:
                openActivity(RegisterActivity.class);
                break;
        }
    }
}
